<%--
  Created by IntelliJ IDEA.
  User: yangpengjie
  Date: 2022/12/26
  Time: 16:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<head>
    <%@include file="/jsp/student/common_css.jsp"%>
    <script src="${pageContext.request.contextPath}/style/js/jquery-3.5.1.js"></script>
</head>
<html>
<div class="col-xl-6 col-lg-6">
    <div class="card">
        <div class="card-header">
            <h4>编辑用户</h4>
        </div>
        <div class="card-body">
            <form name="frm" id="frm">
                <div class="row">
                    <div class="col-xl-6 col-lg-6">
                        <div class="form-group">
                            <%--                for="text-input"--%>
                            <label  class="col-form-label">名字</label>
                            <input name="name" id="name" class="form-control" type="text" placeholder="" value="${data.name}" readonly="readonly">
                        </div>
                    </div>
                    <div class="col-xl-6 col-lg-6">
                        <div class="form-group">
                            <label  class="col-form-label">学号</label>
                            <input name="studentId" id="student_id" class="form-control" type="text" placeholder="" value="${data.studentId}">
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xl-6 col-lg-6">
                        <div class="form-group">
                            <label  class="col-form-label">联系方式</label>
                            <input name="phone" id="phone" class="form-control" type="text" placeholder="" value="${data.phone}">
                        </div>
                    </div>
                    <div class="col-xl-6 col-lg-6">
                        <div class="form-group">
                            <%--                for="text-input"--%>
                            <label  class="col-form-label">身份</label>
                            <input name="identity" id="identity" class="form-control" type="text" placeholder="" value="${data.identity}">
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xl-6 col-lg-6">
                        <div class="form-group">
                            <%--                for="region"--%>
                            <label  class="col-form-label">性别</label>
                            <input name="sex" id="sex" type="text" class="form-control" readonly="readonly" value="${data.sex}">
                        </div>
                    </div>
                    <div class="col-xl-6 col-lg-6">
                        <div class="form-group">
                            <%--                for="text-input"--%>
                            <label class="col-form-label">年龄</label>
                            <%--                id="text-input"--%>
                            <input name="age" id="age" class="form-control" type="text" placeholder="" readonly="readonly" value="${data.age}">
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xl-6 col-lg-6">
                        <div class="form-group">
                            <label class="col-form-label">邮件地址</label>
                            <input name="email" id="email" class="form-control" type="text" value="${data.email}">
                        </div>
                    </div>
                    <div class="col-xl-6 col-lg-6">
                        <div class="form-group">
                            <%--                for="State"--%>
                            <label  class="col-form-label">专业</label>
                            <input name="major" id="major" type="text" class="form-control" readonly="readonly" value="${data.major}" >
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-form-label">身份证号码</label>
                    <input name="identityId" id="identityId" class="form-control" type="text" placeholder="" readonly="readonly" value="${data.identityId}" >
                </div>
                <div class="form-group mb-0">
                    <div class="checkbox mb-3">
                        <input id="checkbox1" type="checkbox">
                        <label for="checkbox1">check me out</label>
                    </div>
                </div>
                <div class="form-group mb-0">
                    <input type="hidden" name="id" value="${data.id}">
                    <%--            <input type="button" onclick="doMessage()" value="提交">--%>
                    <button onclick="doEdit()" class="btn btn-primary squer-btn mt-2 mr-2" type="button">Submit</button>
                </div>
            </form>
        </div>
    </div>
</div>
<%@include file="/jsp/student/common_js.jsp"%>
</html>
<script>
    function doEdit(){
        $.ajax(
            {
                <%--url: "${pageContext.request.contextPath}/studentm",--%>
                url:"${pageContext.request.contextPath}/admin?method=doEditSTeacherMessage",
                type: "post",
                data: $("#frm").serialize(),
                async: false,  //设置同步
                success: function (response) {
                    if (response == 'ok') {
                        alert("用户信息修改成功");
                        setTimeout("window.location.href='/admin?method=TeacherMessageMain'", 1000)
                    } else{
                        alert("编辑用户失败失败，请检查!");
                    }
                }
            }
        )
    }
</script>